/*
 * Copyright (c) 2011-2012 Alexander Dubu
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * o  Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * o  Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * o  Neither the name Axil nor the names of its contributors may be used to
 *    endorse or promote products derived from this software without specific
 *    prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package axil.framework.type;

import axil.api.AxilObject;
import axil.api.Formatted;
import axil.definition.UnitDefinition;
import axil.stdlib.numbers.type.Num;


/**
 * This interface is implemented by any Axil value that contains units. For
 * example:
 *
 * 		32m/s as mph
 *
 * A unitized value object retains the units under which it is constructed.
 * Conversion to different units always produces a new object with those units.
 *
 * Note that money is not considered a unitized type. Currency is not a unit,
 * but currency. Currency conversion is not performed using the "as" operator.
 */
public interface UnitizedValue<T extends AxilObject & Formatted>
	extends AxilObject, Formatted {
	/**
	 * Get the Axil base value within this unitized value. This is the magnitude
	 * or raw value without any unit information.
	 */
	public Num magnitude();


	/**
	 * Get the units for this unitized value. The units returned are never null.
	 */
	public UnitDefinition units();


	/**
	 * Convert this object to another object of the same type, but in different
	 * units.
	 */
	public T as(UnitDefinition units);
}
